﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WhatSNew.AppCode;

namespace WhatSNew.RegisterAndSign
{
    public partial class SignIn : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            UserInfo userInfo = (UserInfo)Session["user"];
            if (userInfo != null)
            {
                Response.Redirect("../User/Personal.aspx");
            }
        }

        protected void SignInBtn_Click(object sender, EventArgs e)
        {
            UserInfoAccess infoAccess = new UserInfoAccess();
            int flag = infoAccess.IsExist(SignInNameTB.Text);
            if ( flag > 0 && 
                SignInPwdTB.Text.Equals(infoAccess.GetUserPInfo(flag).Password))
            {
                UserInfo userInfo = infoAccess.GetUserInfo(flag);
                Session["user"] = userInfo;
                Response.Redirect("../user/Personal.aspx");
            }
            else
            {
                SignInInfoLB.Text = "用户名不存在或密码错误";
                SignInInfoLB.ForeColor = System.Drawing.Color.Red;
                SignInNameTB.Focus();
            }
        }
    }
}